﻿using System;
using System.Windows.Data;

namespace Rio.Framework.Pages.AppCode.Helpers.Converter
{
    public class ExtensionToImageConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            string l_sReturnImagePath;
            string l_oExt = (string)value;

            if (l_oExt.Equals("doc", StringComparison.CurrentCultureIgnoreCase) || l_oExt.Equals("docx", StringComparison.CurrentCultureIgnoreCase))
            {
                l_sReturnImagePath = "../../Assets/Images/FileExtensions/doc.png";
            }
            else if (l_oExt.Equals("xls", StringComparison.CurrentCultureIgnoreCase) || l_oExt.Equals("xlsx", StringComparison.CurrentCultureIgnoreCase))
            {
                l_sReturnImagePath = "../../Assets/Images/FileExtensions/xls.png";
            }
            else if (l_oExt.Equals("pdf", StringComparison.CurrentCultureIgnoreCase))
            {
                l_sReturnImagePath = "../../Assets/Images/FileExtensions/pdf.png";
            }
            else if (l_oExt.Equals("ppt", StringComparison.CurrentCultureIgnoreCase) || l_oExt.Equals("pptx", StringComparison.CurrentCultureIgnoreCase))
            {
                l_sReturnImagePath = "../../Assets/Images/FileExtensions/ppt.png";
            }
            else if (l_oExt.Equals("zip", StringComparison.CurrentCultureIgnoreCase))
            {
                l_sReturnImagePath = "../../Assets/Images/FileExtensions/zip.png";
            }
            else
            {
                l_sReturnImagePath = "../../Assets/Images/FileExtensions/image.png";
            }
            return l_sReturnImagePath;
        }

        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            return value;
        }
    }

    /// <summary>
    /// This method return currently a fix image path to display a folder icone
    /// </summary>
    public class FolderToImageConverter : IValueConverter
    {

        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            return "../../Assets/Images/Folder.png";
        }

        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            return value;
        }
    }

    /// <summary>
    /// This method return currently a fix image path to display a folder icone
    /// </summary>
    public class AlertNumberToImageConverter : IValueConverter
    {

        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            int l_oExt = (int)value;
            return l_oExt > 0 ? "../../Assets/Images/AlertFolder.png" : string.Empty;
        }

        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            return value;
        }
    }
}
